package com.neusoft.controller;

import com.neusoft.service.StudentService;
import org.springframework.context.ApplicationContext;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;

/**
 * @Author: duan
 * @Date: Create in 17:37 2020/10/31
 */
public class BaseController<T> extends HttpServlet {
    private ApplicationContext app;
    @Override
    public void init() throws ServletException {
        System.out.println("init初始化");
        app = (ApplicationContext) getServletContext().getAttribute("app");
    }

    public ApplicationContext getApp() {
        return app;
    }

    public T getServiceBean(Class cls) {
        return (T) app.getBean(cls);
    }
}
